package org.zzz.mapper;

import org.apache.ibatis.annotations.*;
import org.zzz.entity.StudentCourse;

import java.util.List;

/**
 * @Author ZZF
 * @Time 2021/04/20 22:23
 */
public interface StudentCourseMapper {
    /**
     * 添加学生课程
     * @param studentCourse
     * @return
     */
    @Insert("insert into student_course value(#{id},#{sid},#{cid})")
    int insertSC(StudentCourse studentCourse);

    /**
     * 修改学生课程
     * @param studentCourse
     * @return
     */
    @Update("update student_course set cid = #{cid} where id = #{id}")
    int updateSC(StudentCourse studentCourse);

    /**
     * 根据id删除学生课程
     * @param id
     * @return
     */
    @Delete("delete from student_course where id = #{id}")
    int deleteSCById(@Param("id") String id);


    /**
     * 根据学生id获取课程名称
     * @param sid
     * @return
     */
    @Select("select c.name from student_course sc,course c where sc.cid = c.id and sid = #{sid}")
    List<String> listCourseNameBySid(@Param("sid") String sid);

    @Select("select * from student_course sc where sid = #{sid}")
    StudentCourse getSCBySid(@Param("sid") String sid);

    /**
     * 根据课程id获取学生id
     * @param courseId
     * @return
     */
    @Select("select sid from student_course where cid = #{courseId}")
    List<String> listStudentIdByCourseId(@Param("courseId") String courseId);
}
